﻿#region Copyright Notice
// 
// 
//  
//  Copyright (c) 2009-2011 Anindya Chatterjee
//  
//  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//  
//      http://www.apache.org/licenses/LICENSE-2.0
//  
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
// 
// 
#endregion
namespace AbstractClass.NPerf.Framework
{
    /// <summary>
    /// Represents a helper class which exposes a number of constraints used in Asserts.
    /// </summary>
    public static class Is
    {
        /// <summary>
        /// Returns a constraint that checks the specified value against the test
        /// generated value for equality.
        /// </summary>
        /// <param name="value">The specified value to check against the generated
        /// value in the test.</param>
        /// <returns>A <see cref="Constraint"/> to test two values for equality.</returns>
        public static Constraint EqualTo(object value)
        {
            var constraint = new Constraint
                                 {
                                     ConstraintType = ConstraintType.EqualTo,
                                     ObjA = value
                                 };
            return constraint;
        }

        /// <summary>
        /// Returns a constraint that checks whether the test generated value is greater than the
        /// specified value.
        /// </summary>
        /// <param name="value">The specified value to check against the generated
        /// value in the test.</param>
        /// <returns>A <see cref="Constraint"/> to test whether the test generated value is greater
        /// than the specified value.</returns>
        public static Constraint GreaterThan(object value)
        {
            var constraint = new Constraint
                                 {
                                     ConstraintType = ConstraintType.GreaterThan,
                                     ObjA = value
                                 };
            return constraint;
        }

        /// <summary>
        /// Returns a constraint that checks whether the test generated value is less than the
        /// specified value.
        /// </summary>
        /// <param name="value">The specified value to check against the generated
        /// value in the test.</param>
        /// <returns>A <see cref="Constraint"/> to test whether the test generated value is less
        /// than the specified value.</returns>
        public static Constraint LesserThan(object value)
        {
            var constraint = new Constraint
                                 {
                                     ConstraintType = ConstraintType.LesserThan,
                                     ObjA = value
                                 };
            return constraint;
        }

        /// <summary>
        /// Returns a constraint that checks whether the test generated value is greater than 
        /// or equal to the specified value.
        /// </summary>
        /// <param name="value">The specified value to check against the generated
        /// value in the test.</param>
        /// <returns>A <see cref="Constraint"/> to test whether the test generated value is greater
        /// than or equal to the specified value.</returns>
        public static Constraint GreaterOrEqualTo(object value)
        {
            var constraint = new Constraint
                                 {
                                     ConstraintType = ConstraintType.GreaterOrEqualTo,
                                     ObjA = value
                                 };
            return constraint;
        }

        /// <summary>
        /// Returns a constraint that checks whether the test generated value is less than 
        /// or equal to the specified value.
        /// </summary>
        /// <param name="value">The specified value to check against the generated
        /// value in the test.</param>
        /// <returns>A <see cref="Constraint"/> to test whether the test generated value is less
        /// than or equal to the specified value.</returns>
        public static Constraint LesserOrEqualTo(object value)
        {
            var constraint = new Constraint
                                 {
                                     ConstraintType = ConstraintType.LesserOrEqualTo,
                                     ObjA = value
                                 };
            return constraint;
        }

        /// <summary>
        /// Returns a constraint that checks whether the test generated value falls within 
        /// a specified range.
        /// </summary>
        /// <param name="minValue">The minimum value of the range.</param>
        /// <param name="maxValue">The maximum value of the range.</param>
        /// <returns>A <see cref="Constraint"/> to test whether the test generated value falls within 
        /// a specified range.</returns>
        public static Constraint InBetween(object minValue, object maxValue)
        {
            var constraint = new Constraint
                                 {
                                     ConstraintType = ConstraintType.InBetween,
                                     ObjA = minValue,
                                     ObjB = maxValue
                                 };
            return constraint;
        }

        /// <summary>
        /// Returns a constraint that checks whether the test generated value is not equal to 
        /// the specified value.
        /// </summary>
        /// <param name="value">The specified value to check against the generated
        /// value in the test.</param>
        /// <returns>A <see cref="Constraint"/> to test whether the test generated value is not equal to 
        /// the specified value.</returns>
        public static Constraint NotEqualTo(object value)
        {
            var constraint = new Constraint
                                 {
                                     ConstraintType = ConstraintType.NotEqualTo,
                                     ObjA = value
                                 };
            return constraint;
        }
    }
}